<template>
	<view class="conter">
		<template>
			<image src="../../static/logo.png" mode="" style="width: 100%;height: 250rpx;"></image>
			<view class="d-font-26 flex-space-between  add ">
				<view class="d-p-10">
					{{arrlist.cardtype}}
				</view>
				<view class="d-p-10" style="color: #ffaa00;">
					{{arrlist.sale_score}}积分
				</view>
			</view>
			<view class="d-font-26 flex-space-between add d-m-t-10">
				<view class="d-p-10">
					兑换数量
				</view>
				<view class="d-p-10">
					1
				</view>
			</view>
			<view class="d-font-26 flex-column ada d-m-t-10">
				<view class="d-p-10">
					商品描述
				</view>
				<view class="d-p-10" style="color: #b0b0b0;">
					<text v-if="arrlist.adddays>0">有效天数{{arrlist.adddays}}天,</text>此商品价格为{{arrlist.price}}元
				</view>
			</view>
			<view class="d-font-26 flex-column ada d-m-t-10">
				<view class="d-p-10">
					兑换须知
				</view>
				<view class="d-p-10">
					票卡兑换每日限制1张，兑换所有商品属性与现金购买商品完全一致，兑换成功后可在个人中心我的票卡列表所见，饮品泳具等实物商品请至线下前台兑换领取。
				</view>
			</view>
			<view class="d-font-26 flex-space-between add " style="position: fixed;bottom: 0;">
				<view class="d-p-10">
					我的积分<text style="color: #ff0000;">{{jifen}}</text>
				</view>
				<view class="d-p-10 ffs" v-if="arrlist.sale_score > jifen">
					立即兑换
				</view>
				<view class="d-p-10 ffss" v-if="arrlist.sale_score < jifen" @click="duihaun">
					立即兑换
				</view>
			</view>
		</template>
		<customer-Kefu></customer-Kefu>
	</view>
</template>

<script>
	import {
		scoredetail,
		myScore,
		addOrderWithScore
	} from '@/common/api';
	import customerKefu from '../../components/customerKefu/customerKefu.vue';
	export default {
		components: {
			customerKefu
		},
		data() {
			return {
				good_id: '',
				good_type: '',
				arrlist: {},
				jifen: ""
			};
		},
		onLoad(e) {

			this.good_id = e.good_id
			this.good_type = e.good_type
			this.orderclick()
		},
		methods: {
			duihaun() {
				let that = this
				uni.showModal({
					// title: '提示',
					content: '确定兑换吗！',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定后执行的逻辑');
							addOrderWithScore({
									good_id: that.good_id,
									good_type: that.good_type,
									salevenue_id: uni.getStorageSync('venue_id'),
								})
								.then(res => {
									console.log(res, '9966')
									uni.$u.route({
										url: '/pageA/integral/integral'
									});
								})
						} else if (res.cancel) {
							console.log('用户点击取消后执行的逻辑');
						}
					}
				});
			},
			orderclick() {
				scoredetail({
						good_id: this.good_id,
						good_type: this.good_type,
						venue_id: uni.getStorageSync('venue_id'),
					})
					.then(res => {
						console.log(res, '9966')
						this.arrlist = res

					})
				// 我的积分
				myScore()
					.then(res => {
						this.jifen = res
					})
			},

		}
	};
</script>

<style lang="scss" scoped>
	.conter {
		width: 100%;
		height: 100vh;
		background-color: #f5f5f5;

		.add {
			width: 100%;
			height: 80rpx;
			background-color: #fff;
		}

		.ada {
			width: 100%;
			height: auto;
			background-color: #fff;
		}

		.ffs {
			width: 150rpx;
			height: 30rpx;
			background-color: #e7e7e7;
			color: #fff;
			line-height: 30rpx;
			text-align: center;
			border-radius: 40rpx;
		}

		.ffss {
			width: 150rpx;
			height: 30rpx;
			background-color: #ffaa00;
			color: #fff;
			line-height: 30rpx;
			text-align: center;
			border-radius: 40rpx;
		}
	}
</style>